package org.wutopia.labcloud.service.api.service.seata;

import org.apache.seata.rm.tcc.api.BusinessActionContext;
import org.apache.seata.rm.tcc.api.BusinessActionContextParameter;
import org.apache.seata.rm.tcc.api.TwoPhaseBusinessAction;

import java.math.BigDecimal;

public interface TccPaymentService {

    @TwoPhaseBusinessAction(name = "TccProductService",
            commitMethod = "moneyCommit",
            rollbackMethod = "moneyCancel",
            useTCCFence = true)
    Long frozenMoney(BusinessActionContext actionContext,
                @BusinessActionContextParameter(paramName = "payPassword")String payPassword,
                @BusinessActionContextParameter(paramName = "userId")Long userId,
                @BusinessActionContextParameter(paramName = "orderId")Long orderId,
                @BusinessActionContextParameter(paramName = "frozen") BigDecimal frozen) throws Exception;

    boolean moneyCommit(BusinessActionContext actionContext);

    boolean moneyCancel(BusinessActionContext actionContext) throws Exception;



    @TwoPhaseBusinessAction(name = "TccProductService",
            commitMethod = "returnConfirm",
            rollbackMethod = "returnCancel",
            useTCCFence = true)
    boolean moneyReturn(BusinessActionContext actionContext,
                     @BusinessActionContextParameter(paramName = "userId")Long userId,
                     @BusinessActionContextParameter(paramName = "orderId")Long orderId,
                     @BusinessActionContextParameter(paramName = "frozen") BigDecimal frozen) throws Exception;

    boolean returnConfirm(BusinessActionContext actionContext);

    boolean returnCancel(BusinessActionContext actionContext) throws Exception;



    @TwoPhaseBusinessAction(name = "TccProductService",
            commitMethod = "frozenReleaseConfirm",
            rollbackMethod = "frozenReleaseCancel",
            useTCCFence = true)
    boolean frozenRelease(BusinessActionContext actionContext,
                        @BusinessActionContextParameter(paramName = "userId")Long userId,
                        @BusinessActionContextParameter(paramName = "orderId")Long orderId,
                        @BusinessActionContextParameter(paramName = "frozen") BigDecimal frozen) throws Exception;

    boolean frozenReleaseConfirm(BusinessActionContext actionContext);

    boolean frozenReleaseCancel(BusinessActionContext actionContext) throws Exception;

}
